package com.JZ.QM.service.impl;

import com.JZ.QM.common.entity.UserAccountEntity;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;

import com.JZ.QM.common.dao.ProductLibraryIncomeDao;
import com.JZ.QM.common.entity.ProductLibraryIncomeEntity;
import com.JZ.QM.service.ProductLibraryIncomeService;

import javax.annotation.Resource;

/**
 *
 *
 * @author lyp
 * @email lyp@gmail.com
 * @date 2020-06-14 11:19:36
 */
@Service
public class ProductLibraryIncomeServiceImpl extends ServiceImpl<ProductLibraryIncomeDao, ProductLibraryIncomeEntity> implements ProductLibraryIncomeService {

    @Resource
    ProductLibraryIncomeDao productLibraryIncomeDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<ProductLibraryIncomeEntity> page = this.page(
                new Query<ProductLibraryIncomeEntity>().getPage(params),
                new QueryWrapper<ProductLibraryIncomeEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 获取昨日收盘价
     * @param proIncomeTsCode
     * @return
     */
    @Override
    public BigDecimal getPrice(String proIncomeTsCode) {
        //构造查询器
        QueryWrapper<ProductLibraryIncomeEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pro_income_ts_code",proIncomeTsCode);
        //备选库收益信息实体
        ProductLibraryIncomeEntity productLibraryIncomeEntity = new ProductLibraryIncomeEntity();

        productLibraryIncomeEntity = productLibraryIncomeDao.selectOne(queryWrapper);

        return productLibraryIncomeEntity.getProIncomeClose();
    }

}